﻿#pragma once

#include <afxsock.h>
#include "Protocol.h"

// 客户端
class Client: public CSocket {
    private: CWnd* mCallback;           // 回调
    private: int mFriendCount;          // 好友数
    private: int mIconIndex;            // 头像索引
    private: static CString sUsername;  // 用户名

    public: Client(CWnd*);
    public: ~Client();
    public: ResultCode AddFriend(LPCTSTR);
    public: void AllowAddFriend(BOOL, AddFriendRequest*);
    public: void Chat(ChatInfo*);
    public: int GetFriendCount();
    public: static LPCTSTR GetUsername();
    private: void HandleAddFriendRequest(AddFriendRequest*);
    private: void HandleAddFriendResult(AddFriendResult*);
    private: void HandleChat(ChatInfo*);
    private: void HandleFriendLogoff(LogoffRequest*);
    private: void HandleFriendLogon(FriendLogon*);
    private: void HandleLogonResult(LogonResult*);
    private: void HandleRegResult(RegResult*);
    public: void Logoff();
    public: void Logon(LPCTSTR, LPCTSTR);
    private: void OnGetMessageFromServer(ImProtocol*);
    private: virtual void OnReceive(int);
    public: void Reg(LPCTSTR, LPCTSTR, int);
    private: void SendData(ImProtocol*, int);
};
